<template>
  <div class="com-header">
    <span class="back-icon" v-if="defaultConfig.showBackButton" @click="goBackView"><span class="back-title">返回</span></span>
    <h1>{{ defaultConfig.title }}</h1>
    <button class="com-beSureBtn" @click="chilCall()" v-if="defaultConfig.showCompleteBtn">完成</button>
  </div>
</template>

<script>
  export default {
    props: {
      config: {
        type: Object,
        default: function () {
          return {}
        }
      }
    },
    data () {
      return {
        defaultConfig: {
          showBackButton: true,
          title: 'M-web开发框架'
        }
      }
    },
    created () {
      let _this = this
      if (JSON.stringify(_this.config) !== '{}') {
        Object.assign(_this.defaultConfig, _this.config)
      }
    },
    methods: {
      goBackView () {
        this.$router.goBack()
      },
      chilCall() {
        this.$emit('completeEvent', '确定')
      }
    }
  }
</script>

